package com.userautentification.dao.imp;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.userautentification.dao.DataAccessLayerException;
import com.userautentification.dao.HibernateFactory;
import com.userautentification.dao.PersonaDao;
import com.userautentification.entities.Persona;
import com.userautentification.entities.User;

public class PersonaDaoImp extends GenericDaoHibernate<Persona, Long> implements
		PersonaDao {

	Log log = LogFactory.getLog(PersonaDaoImp.class);

	public PersonaDaoImp() {
		HibernateFactory.buildIfNeeded();
	}

	/**
	 * Insert a new Persona into the database.
	 * 
	 * @param persona
	 */
	public void create(Persona persona) throws DataAccessLayerException {
		super.create(persona);
	}

	/**
	 * Delete a detached Persona from the database.
	 * 
	 * @param persona
	 */
	public void delete(Persona persona) throws DataAccessLayerException {
		super.delete(persona);
	}

	/**
	 * Find an Persona by its primary key.
	 * 
	 * @param id
	 * @return
	 */
	public User find(Long id) throws DataAccessLayerException {
		return (User) super.find(Persona.class,id);
	}

	/**
	 * Updates the state of a detached User.
	 * 
	 * @param persona
	 */
	public void update(Persona persona) throws DataAccessLayerException {
		super.update(persona);
	}

	/**
	 * Finds all Persona in the database.
	 * 
	 * @return
	 */
	public List findAll() throws DataAccessLayerException {
		return this.findAll(Persona.class);
	}

}